$(function(){
    $('#treeClose').on('click',function(){
        tree.jstree('close_all');
    }); 
    $('#treeOpen').on('click',function(){
        tree.jstree('open_all');
    }); 
    $('#treeSearch').bind('input propertychange',function(){
        var treeText = $(this).find('>input').val();
        if(treeText){
            tree.jstree('close_all'); 
            tree.jstree(true).search(treeText);
        }else{
            tree.jstree('open_all');
            tree.jstree(true).search(treeText);
        }
    });
})

function treeInit(){
    tree.jstree({ 
        'core': { 
            animation: 300,
            data: null 
        },
        'plugins': [
            'contextmenu',
            'search'
        ],
        contextmenu: {
            items: context_menu
        }
    });
};
function treeRefresh(){
    tree.jstree(true).settings.core.data = Data;
    tree.jstree(true).refresh();
}